(Mujadila) 58 : 12
يَا أَيُّهَا الَّذِينَ آمَنُوا إِذَا نَاجَيْتُمُ الرَّسُولَ فَقَدِّمُوا بَيْنَ يَدَيْ نَجْوَاكُمْ صَدَقَةً ۚ ذَٰلِكَ خَيْرٌ لَكُمْ وَأَطْهَرُ ۚ فَإِنْ لَمْ تَجِدُوا فَإِنَّ اللَّهَ غَفُورٌ رَحِيمٌ

Oh you who believed! It you are intending to consult with the Messenger privately, then you offer a charity prior to your consultation, it is best for you and is the purest; then if you can’t afford it, then indeed Allah is the Forgiving, the Merciful.

The Messenger didn’t accept any compulsory or optional charity for his need. But only accepted ‘Hadya-Gift’. So the object behind commanding to offer charity to Messenger is to reduce the number of consultation with Messenger Muhammed and to make earnings to the public treasury. See explanation 49: 4-7.